﻿<%@ Page Title="" Language="C#" MasterPageFile="~/_User.master" AutoEventWireup="true" CodeBehind="Project.aspx.cs" Inherits="WebApplication.User.Project" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <style>
        .body {
            padding: 10px;
        }
    </style>
    <div class="search-card">
        <div class="search-item" style="height: 34px;">
            <span class="label item">过滤：</span>
            <div class="filter-items">
                <a class="item" filter="1">Ta发布的</a>
                <a class="item" filter="2">Ta应征的</a>
            </div>
        </div>
    </div>

    <script>
        $(function () {

            let url = new URL(location.href);
            let filter= url.searchParams.get('filter') || 1;

            $(`.item[filter=${filter}]`).addClass("active");

            $('.filter-items .item').on('click', (event) => {
                let jNode = $(event.target);
                let url = new URL(location.href);
                let filter = jNode.attr("filter");
                url.searchParams.set("filter", filter);
                location.href = url;
            })
        })
    </script>

    <%--内容--%>
    <div class="layui-row layui-col-space10 mt-20 mb-10">


        <% if (projects.Count > 0)
                { %>
            <% foreach (Models.Projects project in projects)
                { %>

            <div class="layui-col-md6">
                <div class="project-item" url="/Project/Detail.aspx?id=<%=project.ProjectID %>">
                    <div class="info flex-grow-1">
                        <div class="flex-container">
                            <div class="flex-grow-1 title text-ellipsis">
                                <%=project.Title %>
                            </div>
                            <div class="flex-shrink-0  price">
                                ¥ <%=project.PriceMin %> ~ <%=project.PriceMax %>
                            </div>
                        </div>
                        <div class="created">
                            <span class="nickname text-ellipsis"><%=project.Owner.NickName %></span>
                            发布于<%=project.CreatedAt %>
                        </div>
                        <div class="tag">
                            <% if (project.Identity == 1)
                                {%>
                            <span class="el-tag el-tag--mini el-tag--light">私人</span>
                            <%} %>
                            <% if (project.Identity == 2)
                                {%>
                            <span class="el-tag el-tag--mini el-tag--light">社团/店铺</span>
                            <%} %>
                            <% if (project.Identity == 3)
                                {%>
                            <span class="el-tag el-tag--mini el-tag--light">公司企业</span>
                            <%} %>

                            <%
                                List<string> tags = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(project.Tag);
                                tags.Remove("@");
                                foreach (string tag in tags)
                                {
                            %>
                            <span class="el-tag el-tag--info el-tag--mini el-tag--light"><%=tag %></span>
                            <%} %>
                        </div>
                        <div class="info2">
                            <div class="label-wrapper">
                                <span class="label">截稿日期：</span>
                                <span class="value"><%=project.Deadline.ToString("yyyy-MM-dd") %></span>
                            </div>
                            <div class="label-wrapper">
                                <span class="label">应征人数：</span>
                                <span class="value"><%=project.ApplyCount %></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <%} %>

            <script>
                $('.project-item').on('click', e => {
                    let url = $(e.delegateTarget).attr("url");
                    if (url) {
                        window.open(url);
                    }
                })
            </script>
            <%}
                else
                { %>

            <div class="empty"></div>

            <%} %>


    </div>
</asp:Content>
